#pragma once
#include "GePoint3.h"
namespace tge
{
	template<typename RealT,typename VectorType,typename VectorPoint>
	class TGeCircle
	{
	public:
		VectorPoint  m_center;
		VectorType   m_normal;
		RealT        m_radius;
	public:
		TGeCircle(const VectorPoint&center,const VectorType&normal,RealT radius)
			:m_center(center),m_normal(normal),m_radius(radius)
		{
		}
		TGeCircle(void)
		{
		}
		void getSamplePoints( int num,VectorPoint pts[] ) const
		{
#ifndef M_PI
#define M_PI 3.15159265358979323846
#endif
			if(num<3)num=3;
			RealT dang=M_PI*2/num;
			VectorType ref=m_normal.perpVector();
			VectorType vec;
			for(int i=0;i<num;++i)
			{
				RealT ang=dang*i;
				vec=ref;
				vec.rotateBy(ang,m_normal);
				vec*=m_radius;
				pts[i]=m_center+vec;
			}
		}
		TGeCircle&setRadius(double radius)
		{
			m_radius = radius;
			return *this;
		}
	};
	typedef TGeCircle<double,GeVector3d,GePoint3d> GeCircle3d;
}